﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace GroundWater
{
    public class ApplicationContext
    {
        public static string Theme
        {
            get
            {
                //从客户端取
                string theme = SiteUtil.GetString(SiteConstants.CurrentTheme);
                string themeDir = HttpContext.Current.Server.MapPath("App_Themes");
                // E:\Projects\Private\GroundWater\GroundWater\App_Themes
                if (String.IsNullOrEmpty(theme) || !System.IO.Directory.Exists(themeDir + "\\" + theme))
                {
                    //从配置中取
                    //UIConfiguration ui = ApplicationConfiguration.GetUIConfiguration(CurrentOwnerId.Value, UserId);
                    //theme = ui.Theme;

                    //如果从配置中取不到，就直接赋默认值:Silver
                    if (String.IsNullOrEmpty(theme) || !System.IO.Directory.Exists(themeDir + "\\" + theme))
                    {
                        theme = "default";
                    }

                    SiteUtil.SetString(SiteConstants.CurrentTheme, theme);
                }

                return theme;
            }
        }
    }
}
